#include "AttributeHolder.h"

AttributeHolder::AttributeHolder(std::map<std::string,int> *_sessionAttributes)
{
	sessionAttributes = _sessionAttributes;
}

AttributeHolder::~AttributeHolder()
{
}

	void AttributeHolder::setPool(DataPool *_pool) {
		pool=_pool;
	}
	DataPool* AttributeHolder::getPool() {
		return pool;
	}

	int AttributeHolder::getRequestAttribute(std::string key){
//		std::map<std::string,int>::iterator it;
//		std::map<std::string,int>::iterator it2;
//		it = requestAttributes.find(key);
//		it2 = requestAttributes.end();
////		printf("it end %d %d \n",(int)*it,(int)*it2);
//		if (it==it2)
//			return 0;
//		return it->second;
		return requestAttributes[key];
	}
	void AttributeHolder::setRequestAttribute(std::string key,int pointer){
//		requestAttributes.insert(std::pair<std::string,int>(key,pointer));
		requestAttributes[key]=pointer;
	}
	
	int AttributeHolder::getSessionAttribute(std::string key){
//		std::map<std::string,int>::iterator it;
//		std::map<std::string,int>::iterator it2;
//		it2 = sessionAttributes->end();
//		it = sessionAttributes->find(key);
////		printf("it end %d %d \n",(int)&it,(int)&it2);
//		if (it==it2)
//			return 0;
//		return it->second;
		return (*sessionAttributes)[key];
	}
	void AttributeHolder::setSessionAttribute(std::string key,int pointer){
//		sessionAttributes->insert(std::pair<std::string,int>(key,pointer));
		(*sessionAttributes)[key]=pointer;
	}

	int AttributeHolder::counter = 0;
	
	